<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/struts/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="./style/alternative.css" media="all" rel="stylesheet" />
<style type="text/css">
#goalList {
    width:95%;
}
#goalList th {
    text-align:center;
}
.goalAction {
text-align:center;
white-space: nowrap;
}
.goalCell {
white-space: nowrap;
text-align:left;
}
</style>
<script type='text/javascript' src='script/prototype.js'></script>
<script type='text/javascript' src='script/common.js'></script>

<SCRIPT LANGUAGE="JavaScript">
var checkedAll = false;

function onDelete(){
     var s = $$('#table input');
     var trs = $$('#table tr');
     for(var i=s.length-1; i>=0; i--)
     {
      if (s[i].checked)
       trs[i].remove();
     }

}
function checkForm(){
    var checked = "";
    $$('input[type="checkbox"][name="itemID"]').select(function(i){return i.checked}).each(function(i)
    {
       //alert(i.value)
       checked = checked + i.value;
    });  
    if(checked=="") {
        alert("请选择一个事务");
        return false;
    }
    return true;
    
} 


function submitForm(method) {
    var ret = true;
    if(method!="add") {
        ret = checkForm();
    }
    if(ret) {
        $("method").value=method;
        $("goalsForm").submit();
    }
}

function doDelete(goalID, goalType) {
    //goal.htm?method=delete&goalID=${goal.goalID}&goalType=${param.goalType} {
        var ret = confirm("你确信删除这项目标吗?");
        if(ret) {
            location.href = "goal.htm?method=delete&goalID=" + goalID + "&goalType=" + goalType;
        }
    
}
</SCRIPT>
</head>
<body>
<div id="content"><div id="content_inner">
<form name="goalsForm" id="goalsForm" method="get" action="goal.htm">
<BR><center>
<h2>我的目标</h2>
</center>

<display:table htmlId="goalList" name="goalList" sort="list" 
     class="its" id="goal" requestURI="goal.htm">
<display:setProperty name="basic.empty.showtable" value="true" />
<display:setProperty name="basic.msg.empty_list_row" value="<tr class='empty'><td colspan='{0}'>没有记录</td></tr>"/>
<display:column style="width:30%" title="目标" sortable="true" headerClass="sortable">
<img src="images/bullet.gif"/>&nbsp;<a href="goal.htm?method=edit&goalID=${goal.goalID}&goalType=${param.goalType}">${goal.goalName}</a>
</display:column>
<display:column  style="width:20%" property="description" title="细节" sortable="true" headerClass="sortable"/>
<display:column title="<select id=\"goalType\" name=\"goalType\">
<option value=\"0\">所有目标</option>
<option value=\"1\">长期目标</option>
<option value=\"2\">中期目标</option>
<option value=\"3\">短期目标</option>
<option value=\"4\">本月目标</option>
<option value=\"5\"\">本周目标</option>
<option value=\"6\">当天目标</option>
</select>" headerClass="sortable">
<span class="goalCell"><c:choose>
<c:when test="${goal.goalType==1}">
长期
</c:when>
<c:when test="${goal.goalType==2}">
中期
</c:when>
<c:when test="${goal.goalType==3}">
短期
</c:when>
<c:when test="${goal.goalType==4}">
本月
</c:when>
<c:when test="${goal.goalType==5}">
本周
</c:when>
<c:when test="${goal.goalType==6}">
当天
</c:when>
<c:otherwise>
所有
</c:otherwise>
</c:choose></span>
</display:column>
<display:column title="类型" sortable="true" headerClass="goalCell">
${categories[goal.categoryID].description}
</display:column>
<display:column title="开始时间" sortable="true" headerClass="sortable">
<fmt:formatDate value="${goal.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
</display:column>
<display:column title="截止时间" sortable="true" headerClass="sortable">
<fmt:formatDate value="${goal.deadline}" pattern="yyyy-MM-dd HH:mm:ss"/>
</display:column>
<display:column title="<img src='images/add.png' WIDTH='50' HEIGHT='50'  onclick=\"submitForm('add')\" value=\"添加目标\"/>" class="goalAction">
<a href="goal.htm?method=edit&goalID=${goal.goalID}&goalType=${param.goalType}" class="icon_btn pic_edit" title="Edit Task"><span>Edit Goal</span></a>
<a href="#" onclick="doDelete(${goal.goalID}, '${goal.goalType}')" class="icon_btn pic_delete" title="Delete Task"><span>Delete Goal</span></a>
</display:column> 
</display:table>
<div>
<input type="hidden" name="method" id="method">
</div>
</form>
</div><!-- content_inner -->
</div><!-- content -->

<script language="Javascript">
var defaultGoalType = "" + "${param.goalType}";
if(defaultGoalType=="") {
    defaultGoalType = 0;
}
toSelect("goalType",defaultGoalType);
</script>